<template>
  <div>
    <!--    搜索栏-->
    <div class="tb-head">
      <el-row :gutter="10">
        <el-col :span="4">
          <div>
            <search title="检验单号" :url="findCheckOrder" :table-fields="checkOrderFields" :index="qcbadocno"
                    ref="CheckOrder" allowCheck="1"></search>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <div>
              <el-date-picker v-model="queryParams.qcbadocdt" type="date" placeholder="单据日期" value-format="yyyy-MM-dd"></el-date-picker>
            </div>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <div>
              <el-date-picker v-model="queryParams.qcbacnfdt" type="date" placeholder="审核日期"
                              value-format="yyyy-MM-dd"></el-date-picker>
            </div>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <el-select v-model="queryParams.qcbastus" placeholder="状态" clearable>
              <el-option v-for="item in statueList" :key="item.value" :label="item.label"
                         :value="item.value" ></el-option>
            </el-select>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <el-select v-model="queryParams.qcba000" placeholder="检验类型" clearable>
              <el-option v-for="item in checkTypeList" :key="item.value" :label="item.label"
                         :value="item.value"></el-option>
            </el-select>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <search title="来源单号" allowCheck="1" :url="findFormOrder" :index="qcba001" :table-fields="formOrderFields"
                    ref="formOrder"></search>
          </div>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="4">
          <div>
            <el-input placeholder="来源项次" v-model="queryParams.qcba002" clearable></el-input>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <search title="交易对象编号" allowCheck="1" :table-fields="TransactionFieldx" :url="findTransaction"
                    ref="transaction" :index="pmaa001"></search>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <el-input placeholder="交易对象名称" v-model="queryParams.pmaal003" clearable></el-input>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <search title="检验员" allowCheck="1" :url="findCheckUser" :table-fields="checkUserFields" ref="checkUser"
                    :index="ooag001"></search>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <el-select v-model="queryParams.qcba022" placeholder="判定结果" clearable>
              <el-option v-for="item in checkResultList" :key="item.value" :label="item.label"
                         :value="item.value"></el-option>
            </el-select>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <search title="料号" allowCheck="1" :url="findItem" :index="imaa001" :table-fields="itemFields"
                    ref="item"></search>
          </div>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="4">
          <div>
            <el-input placeholder="品名" v-model="queryParams.imaal003" clearable></el-input>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <el-input placeholder="规格" v-model="queryParams.imaal004" clearable></el-input>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <el-input placeholder="工程图号" v-model="queryParams.imaa041" clearable></el-input>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <el-input placeholder="送验量" v-model="queryParams.qcba017" clearable></el-input>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <el-input placeholder="合格量" v-model="queryParams.qcba023" clearable></el-input>
          </div>
        </el-col>
        <el-col :span="4">
          <div>
            <el-input placeholder="不良数" v-model="queryParams.qcba027" clearable></el-input>
          </div>
        </el-col>
      </el-row>
    </div>
    <div>
      <el-button icon="el-icon-search" type="success" @click="searchTable">查找</el-button>
    </div>
    <!--    查询记录 表格-->
    <div class="tb-body">
      <DYTable :table-fields="tableFields" :result="dataTable" allowCheck="1"></DYTable>
    </div>
    <!--    分页-->
    <pagination
        :v_show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="loadTable"
    />
  </div>
</template>

<script>
import {
  listtransactionTable,
  listitemTable,
  listcheckUserTable,
  listformOrderTable,
  listcheckOrderTable,
  loadListTable
} from '@/api/T100/cqcq001'

export default {
  name: "cqcq001",
  data() {
    return {
      findTransaction: listtransactionTable,
      findItem: listitemTable,
      findCheckUser: listcheckUserTable,
      findFormOrder: listformOrderTable,
      findCheckOrder: listcheckOrderTable,
      itemFields: [{label: '料号', prop: 'imaa001'}, {label: '品名', prop: 'imaal003'}, {label: '规格', prop: 'imaal004'}],
      checkUserFields: [{label: '员工编号', prop: 'ooag001'}, {label: '员工全名', prop: 'ooag011'}],
      TransactionFieldx: [{label: '交易对象编号', prop: 'pmaa001'}, {label: '交易对象全名', prop: 'pmaal003'},
        {
          label: '交易对象简称',
          prop: 'pmaal004'
        }, {label: '税号', prop: 'pmaa003'}, {label: '所属法人', prop: 'pmaa005'}, {label: '供应商分类', prop: 'pmaa080'}],
      checkOrderFields: [{label: '检验单号', prop: 'qcbadocno'}, {label: '单据日期', prop: 'qcbadocdt'}, {
        label: '来源单号',
        prop: 'qcba001'
      }, {label: '来源项次', prop: 'qcba002'}],
      formOrderFields: [{label: '来源单号', prop: 'qcba001'}],
      statueList: [{value: 'A', label: '已核准'}, {value: 'D', label: '已抽单'}, {value: 'N', label: '未审核'}, {
        value: 'R',
        label: '已拒绝'
      }, {value: 'W', label: '送签中'}, {value: 'X', label: '作废'}, {value: 'Y', label: '已审核'}],
      checkTypeList: [{value: '0', label: '全通用'}, {value: '1', label: 'IQC'}, {value: '2', label: 'FQC'}, {
        value: '3',
        label: 'PQC'
      }, {value: '4', label: 'OQC'}, {value: '5', label: 'Inventory QC'}, {value: '6', label: 'RQC'}],
      checkResultList: [{value: '0', label: '检验中'}, {value: '1', label: '合格'}, {value: '2', label: '验退'}, {
        value: '3',
        label: '返工'
      }, {value: '4', label: '特采'}, {value: '5', label: '报废'}],
      tableFields: [{label: '检验单号', prop: 'qcbadocno'}, {label: '单据日期', prop: 'qcbadocdt'}, {
        label: '审核日期',
        prop: 'qcbacnfdt'
      }, {label: '状态', prop: 'qcbastus'}, {label: '检验类型', prop: 'qcba000'},
        {label: '来源单号', prop: 'qcba001'}, {label: '来源项次', prop: 'qcba002'}, {
          label: '交易对象编号',
          prop: 'qcba005'
        }, {label: '交易对象名称', prop: 'pmaal003'}, {label: '检验员', prop: 'qcba024'},
        {label: '检验员', prop: 'jyy'}, {label: '判定结果', prop: 'qcba022'}, {label: '料号', prop: 'qcba010'}, {
          label: '品名',
          prop: 'imaal003'
        }, {label: '规格', prop: 'imaal004'}, {label: '工程图号', prop: 'imaa041'},
        {label: '送检量', prop: 'qcba017'}, {label: '合格量', prop: 'qcba023'}, {label: '不良数', prop: 'qcba027'}],
      dataTable: [],
      qcbadocno: 'qcbadocno',
      qcba001: 'qcba001',
      pmaa001: 'pmaa001',
      ooag001: 'ooag001',
      imaa001: 'imaa001',
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        qcbadocdt: '',
        qcbacnfdt: '',
        qcbastus: '',
        qcba000: '',
        qcba002: '',
        pmaal003: '',
        qcba022: '',
        imaal003: '',
        imaal004: '',
        imaa041: '',
        qcba017: '',
        qcba023: '',
        qcba027: '',
      },
    }
  },
  methods: {
    loadTable() {
      this.searchTable()
    },
    searchTable() {
      this.queryParams.qcbadocno = this.$refs.CheckOrder.queryParams.keyword
      this.queryParams.qcba001 = this.$refs.formOrder.queryParams.keyword
      this.queryParams.qcba005 = this.$refs.transaction.queryParams.keyword
      this.queryParams.qcba024 = this.$refs.checkUser.queryParams.keyword
      this.queryParams.qcba010 = this.$refs.item.queryParams.keyword
      // this.queryParams.pmaal003 = encodeURI(this.queryParams.pmaal003)
      loadListTable(this.queryParams).then(resp => {
        if (resp.code == '200') {
          this.dataTable = resp.rows
          this.total = resp.total
        } else {
          this.$message.warning('查询失败！请稍后再试')
        }
      })
    },
  },
}
</script>

<style scoped lang="scss">
.tb-head > div {
  margin: 5px;
}

.tb-head {
  margin: 5px;
}

.tb-body {
  margin: 5px;
}
</style>
